package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.VisitGuide;
import com.ruoyi.system.service.IVisitGuideService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 就诊指南Controller
 * 
 * @author ruoyi
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/system/guide")
public class VisitGuideController extends BaseController
{
    @Autowired
    private IVisitGuideService visitGuideService;



    /**
     * 查询就诊指南列表
     */
    @PreAuthorize("@ss.hasPermi('system:guide:list')")
    @GetMapping("/list")
    public TableDataInfo list(VisitGuide visitGuide)
    {
        startPage();
        List<VisitGuide> list = visitGuideService.selectVisitGuideList(visitGuide);
        return getDataTable(list);
    }

    /**
     * 导出就诊指南列表
     */
    @PreAuthorize("@ss.hasPermi('system:guide:export')")
    @Log(title = "就诊指南", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VisitGuide visitGuide)
    {
        List<VisitGuide> list = visitGuideService.selectVisitGuideList(visitGuide);
        ExcelUtil<VisitGuide> util = new ExcelUtil<VisitGuide>(VisitGuide.class);
        util.exportExcel(response, list, "就诊指南数据");
    }

    /**
     * 获取就诊指南详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:guide:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(visitGuideService.selectVisitGuideById(id));
    }

    /**
     * 新增就诊指南
     */
    @PreAuthorize("@ss.hasPermi('system:guide:add')")
    @Log(title = "就诊指南", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VisitGuide visitGuide)
    {
        return toAjax(visitGuideService.insertVisitGuide(visitGuide));
    }

    /**
     * 修改就诊指南
     */
    @PreAuthorize("@ss.hasPermi('system:guide:edit')")
    @Log(title = "就诊指南", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VisitGuide visitGuide)
    {
        return toAjax(visitGuideService.updateVisitGuide(visitGuide));
    }

    /**
     * 删除就诊指南
     */
    @PreAuthorize("@ss.hasPermi('system:guide:remove')")
    @Log(title = "就诊指南", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(visitGuideService.deleteVisitGuideByIds(ids));
    }

    /**
     * 根据分类id查询所有分类下的文章
     */
    @GetMapping("/selectSameCateId/{cateId}")
    public AjaxResult selectSameCateId(@PathVariable("cateId") Integer cateId){
        return success(visitGuideService.selectSameCateId(cateId));
    }
}
